window.onload= function () {
    // 捉到6个图像盒子
    box_item = document.getElementsByClassName('box_item');
    // 捉到6个点
    click_item = document.getElementsByClassName("click_item");

    // 开启定时器
    time = setInterval(run,1000);
    //设置每次要跑的第几张
    num = 0;
    // 1秒执行一次
    function run() {
        //让所的有图像消失
        for (var i = 0; i < box_item.length; i++) {
            box_item[i].style.display="none";
            click_item[i].style.backgroundColor ="rgba(0,0,0,0.7)";
        }
        //让某一张出现 
        box_item[num].style.display="block";
        click_item[num].style.backgroundColor ="rgba(255,255,255,0.7)";
        
        // 递增
        num++;
        //走到最后一张置为第一张
        if(num==box_item.length){
            num = 0;
        }
    }
    //进去这个区域停定时器
    banner = document.getElementById('banner');
    //进入
    banner.onmouseover = function () {
        clearInterval(time);
    }
    //出去
    banner.onmouseout = function () {
        time = setInterval(run,1000);
    }
    //给每个点加点击事件
    for (var i =0; i <click_item.length; i++) {
        click_item[i].index = i;
        click_item[i].onclick = function () {
            // index = this.getAttribute('key');
            index = this.index;
            num = index;
            run();
        }
    }
    //加点右的加点击 事件
    click_right = document.getElementById('click_right');

    click_right.onclick= function () {
        run();
    }
    //加点左的加点击 事件
    click_left = document.getElementById('click_left');

    click_left.onclick= function () {
        num -=2;
        run();
    }
}